<?php

/**
 *706. 设计哈希映射
 *
 */
    class MyHashMap {
        private $_map = [];
        /**
         */
        function __construct() {

        }

        /**
         * @param Integer $key
         * @param Integer $value
         * @return NULL
         */
        function put($key, $value) {
            $this->_map[$key] = ['key' => $key,'value' => $value];
        }

        /**
         * @param Integer $key
         * @return Integer
         */
        function get($key) {
            return isset($this->_map[$key]['value'])?$this->_map[$key]['value']:-1;
        }

        /**
         * @param Integer $key
         * @return NULL
         */
        function remove($key) {
            unset($this->_map[$key]);
        }
    }

    Class Solution {
        /**
         * 709. 转换成小写字母
         * @param String $s
         * @return String
         */
        function toLowerCase709($s) {
            return strtolower($s);
        }

        /**
         * 717. 1 比特与 2 比特字符
         * @param Integer[] $bits
         * @return Boolean
         */
        function isOneBitCharacter717($bits) {
            $i = 0;
            while($i < count($bits) - 1){
                if($bits[$i] == 1) {
                    $i += 2;
                }else{
                    $i += 1;
                }
            }

            return $i == count($bits) - 1;
        }

        /**
         * 724. 寻找数组的中心下标
         * @param Integer[] $nums
         * @return Integer
         */
        function pivotIndex724($nums) {
            $leftsum = 0;
            $i = 0;
            while($i < count($nums)){
                if((2 * $leftsum + $nums[$i]) == array_sum($nums)){
                    return $i;
                }
                $leftsum += $nums[$i];
                $i++;
            }

            return -1;
        }

        /**
         * 728. 自除数
         * @param Integer $left
         * @param Integer $right
         * @return Integer[]
         */
        function selfDividingNumbers728($left, $right) {
            $map = [];
            while($left <= $right) {
                $i = 0;
                $flag = true;
                $left = strval($left);
                while($i < strlen($left)){
                    if($left[$i] == 0 || $left % $left[$i] != 0){
                        $flag = false;
                        break;
                    }
                    $i++;
                }
                if($flag){
                    $map[] = $left;
                }
                $left++;
            }

            return $map;
        }

        /**
         * 744. 寻找比目标字母大的最小字母
         * @param String[] $letters
         * @param String $target
         * @return String
         */
        function nextGreatestLetter744($letters, $target) {
            if($letters[count($letters) - 1] <= $target){
                return $letters[0];
            }
            foreach($letters as $letter){
                if($letter > $target){
                    return $letter;
                }
            }
        }



    }
    $solution = new Solution();
    $left = 15;
    $right = 22;
    print_r($solution->selfDividingNumbers728($left, $right));

?>